/*
 * PanelMenu.fx
 *
 * Created on 3/10/2010, 10:05:41 PM
 */
package restaurante;

import org.netbeans.javafx.design.DesignState;
import javafx.scene.layout.LayoutInfo;
import javafx.scene.layout.Panel;
import javafx.scene.Node;
import menu.menu.Menu;
import java.util.Collection;
import menu.menu.MenuFX;

/**
 * @author Camilo
 * @version $Id: PanelMenu.fx 67 2010-10-06 21:18:49Z lopezandres2002@hotmail.com $
 */
public class PanelMenu {

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:main
    def __layoutInfo_listView: javafx.scene.layout.LayoutInfo = javafx.scene.layout.LayoutInfo {
        width: 515.0
        height: 550.0
    }
    public-read def listView: javafx.scene.control.ListView = javafx.scene.control.ListView {
        layoutX: 57.0
        layoutY: 68.0
        layoutInfo: __layoutInfo_listView
        items: bind listViewItems
    }
    
    public-read def rectangle: javafx.scene.shape.Rectangle = javafx.scene.shape.Rectangle {
        visible: false
        layoutX: 178.0
        layoutY: 164.0
        width: 100.0
        height: 50.0
    }
    
    public-read def botonVolver: javafx.scene.control.Button = javafx.scene.control.Button {
        visible: false
        layoutX: 319.0
        layoutY: 337.0
        text: "Button"
    }
    
    public-read def labelModal: javafx.scene.control.Label = javafx.scene.control.Label {
        visible: false
        layoutX: 131.0
        layoutY: 166.0
        text: bind labelModalText
    }
    
    public-read def rectangle2: javafx.scene.shape.Rectangle = javafx.scene.shape.Rectangle {
        visible: false
        layoutX: 222.0
        layoutY: 181.0
        width: 100.0
        height: 50.0
    }
    
    public-read def rectangle3: javafx.scene.shape.Rectangle = javafx.scene.shape.Rectangle {
        visible: false
        layoutX: 207.0
        layoutY: 175.0
        width: 100.0
        height: 50.0
    }
    
    public-read def image: javafx.scene.image.Image = javafx.scene.image.Image {
        url: "{__DIR__}imagenes/PageTemplate.jpg"
        width: 624.0
        height: 599.0
        preserveRatio: false
    }
    
    public-read def sepiaLibro: javafx.scene.effect.SepiaTone = javafx.scene.effect.SepiaTone {
        level: 1.0
    }
    
    public-read def imageView: javafx.scene.image.ImageView = javafx.scene.image.ImageView {
        opacity: 0.92
        layoutX: 0.0
        layoutY: 50.0
        effect: sepiaLibro
        image: image
        fitWidth: 0.0
        fitHeight: 0.0
    }
    
    def __layoutInfo_panel: javafx.scene.layout.LayoutInfo = javafx.scene.layout.LayoutInfo {
        width: 624.0
        height: 768.0
    }
    public-read def panel: javafx.scene.layout.Panel = javafx.scene.layout.Panel {
        visible: true
        layoutInfo: __layoutInfo_panel
        content: [ imageView, listView, rectangle, botonVolver, labelModal, rectangle2, rectangle3, ]
    }
    
    public-read def color: javafx.scene.paint.Color = javafx.scene.paint.Color {
        red: 0.27450982
        green: 0.03137255
        blue: 0.03137255
    }
    
    public-read def currentState: org.netbeans.javafx.design.DesignState = org.netbeans.javafx.design.DesignState {
        names: [ "init", "modalItem", "modalChat", ]
        actual: 0
        timelines: [
            javafx.animation.Timeline {
                keyFrames: [
                    javafx.animation.KeyFrame {
                        time: 0ms
                        action: function() {
                            imageView.visible = true;
                            imageView.disable = false;
                            imageView.opacity = 0.92;
                            imageView.effect = sepiaLibro;
                            listView.disable = false;
                            listView.opacity = 1.0;
                            listView.onMouseClicked = listViewOnMouseClickedAtinit;
                            listView.effect = null;
                            rectangle.visible = false;
                            rectangle.layoutX = 178.0;
                            rectangle.layoutY = 164.0;
                            rectangle.fill = javafx.scene.paint.Color.BLACK;
                            rectangle.width = 100.0;
                            rectangle.height = 50.0;
                            botonVolver.visible = false;
                            botonVolver.layoutX = 319.0;
                            botonVolver.layoutY = 337.0;
                            botonVolver.onMouseClicked = null;
                            botonVolver.text = "Button";
                            labelModal.visible = false;
                            labelModal.disable = false;
                            labelModal.layoutX = 131.0;
                            labelModal.layoutY = 166.0;
                            rectangle3.visible = false;
                            rectangle3.opacity = 1.0;
                            rectangle3.layoutX = 207.0;
                            rectangle3.layoutY = 175.0;
                            rectangle3.translateX = 0.0;
                            rectangle3.translateY = 0.0;
                            rectangle3.fill = javafx.scene.paint.Color.BLACK;
                            rectangle3.smooth = true;
                            rectangle3.x = 0.0;
                            rectangle3.y = 0.0;
                            rectangle3.width = 100.0;
                            rectangle3.height = 50.0;
                            panel.disable = false;
                            panel.opacity = 1.0;
                            panel.effect = null;
                        }
                    }
                ]
            }
            javafx.animation.Timeline {
                keyFrames: [
                    javafx.animation.KeyFrame {
                        time: 0ms
                        action: function() {
                            imageView.visible = true;
                            imageView.disable = true;
                            imageView.opacity = 1.0;
                            imageView.effect = sepiaLibro;
                            imageView.smooth = false;
                            listView.disable = false;
                            listView.opacity = 0.45;
                            listView.onMouseClicked = null;
                            listView.effect = null;
                            rectangle.visible = true;
                            rectangle.layoutX = 125.0;
                            rectangle.layoutY = 142.0;
                            rectangle.fill = javafx.scene.paint.Color.WHITE;
                            rectangle.width = 284.0;
                            rectangle.height = 228.0;
                            botonVolver.visible = true;
                            botonVolver.layoutX = 337.0;
                            botonVolver.layoutY = 337.0;
                            botonVolver.onMouseClicked = botonVolverOnMouseClickedAtmodalItem;
                            botonVolver.text = "Volver";
                            labelModal.visible = true;
                            labelModal.disable = false;
                            labelModal.layoutX = 148.0;
                            labelModal.layoutY = 166.0;
                            rectangle3.visible = false;
                            rectangle3.opacity = 1.0;
                            rectangle3.layoutX = 207.0;
                            rectangle3.layoutY = 175.0;
                            rectangle3.translateX = 0.0;
                            rectangle3.translateY = 0.0;
                            rectangle3.fill = javafx.scene.paint.Color.BLACK;
                            rectangle3.smooth = true;
                            rectangle3.x = 0.0;
                            rectangle3.y = 0.0;
                            rectangle3.width = 100.0;
                            rectangle3.height = 50.0;
                            panel.disable = false;
                            panel.opacity = 1.0;
                            panel.effect = null;
                        }
                    }
                ]
            }
            javafx.animation.Timeline {
                keyFrames: [
                    javafx.animation.KeyFrame {
                        time: 0ms
                        values: [
                            rectangle3.translateX => rectangle3.translateX tween javafx.animation.Interpolator.DISCRETE,
                        ]
                        action: function() {
                            imageView.visible = true;
                            imageView.disable = false;
                            imageView.opacity = 0.92;
                            imageView.effect = sepiaLibro;
                            listView.disable = true;
                            listView.opacity = 1.0;
                            listView.onMouseClicked = listViewOnMouseClickedAtinit;
                            listView.effect = null;
                            rectangle.visible = false;
                            rectangle.layoutX = 178.0;
                            rectangle.layoutY = 164.0;
                            rectangle.fill = javafx.scene.paint.Color.BLACK;
                            rectangle.width = 100.0;
                            rectangle.height = 50.0;
                            botonVolver.visible = false;
                            botonVolver.layoutX = 319.0;
                            botonVolver.layoutY = 337.0;
                            botonVolver.onMouseClicked = null;
                            botonVolver.text = "Button";
                            labelModal.visible = false;
                            labelModal.disable = false;
                            labelModal.layoutX = 131.0;
                            labelModal.layoutY = 166.0;
                            rectangle3.visible = true;
                            rectangle3.opacity = 1.0;
                            rectangle3.layoutX = 0.0;
                            rectangle3.layoutY = 250.0;
                            rectangle3.translateY = 0.0;
                            rectangle3.effect = null;
                            rectangle3.fill = javafx.scene.paint.Color.WHITE;
                            rectangle3.smooth = true;
                            rectangle3.x = -300.0;
                            rectangle3.y = 0.0;
                            rectangle3.width = 300.0;
                            rectangle3.height = 400.0;
                            panel.disable = false;
                            panel.opacity = 1.0;
                            panel.effect = null;
                        }
                    }
                    javafx.animation.KeyFrame {
                        time: 500ms
                        values: [
                            rectangle3.translateX => 300.0 tween javafx.animation.Interpolator.LINEAR,
                        ]
                    }
                ]
            }
        ]
    }
    
    public function getDesignRootNodes (): javafx.scene.Node[] {
        [ panel, ]
    }
    // </editor-fold>//GEN-END:main

    /**
     *   Parte donde se hace el bind entre la lista existente en Menu y lo que se muestra en pantalla
     *   menu es la instancia del Menu dada por el patrón singleton
     */
    var menu: Menu = Menu.getInstance();
    var menuFX: MenuFX = MenuFX.instance;
    var lista: Collection = bind menu.getItems();
    var listViewItems: Object[] = bind lista.toArray();
    var labelModalText: String = bind listView.selectedItem.toString();

    var visibilidad: Integer = bind menuFX.chat;
    var chat: Integer = bind visibilidad on replace {
                if (chat == 1) {
                    currentState.actual = currentState.findIndex("modalChat");
                } else {
                    currentState.actual = currentState.findIndex("init");
                }

            }
    var labelText: String = "";

    function botonVolverOnMouseClickedAtmodalItem(event: javafx.scene.input.MouseEvent): Void {
        currentState.actual = currentState.findIndex("init");
    }

    function listViewOnMouseClickedAtinit(event: javafx.scene.input.MouseEvent): Void {
        currentState.actual = currentState.findIndex("modalItem");
    }

}

function run (): Void {
    var design = PanelMenu {};

    javafx.stage.Stage {
        title: "PanelMenu"
        scene: javafx.scene.Scene {
            content: design.getDesignRootNodes ()
        }
    }
}
